<%@include file="/WEB-INF/jsp/taglib.jsp" %>
<c:import url="/WEB-INF/jsp/frontend/script.jsp"/>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<div id="allcontent" style="height:423px; background:#FFFFFF; margin-top:10px; padding:0px 5px; " align="center">
    <div id="catogory">
        <b>
            <span style="color:Red">管理版块</span>
        </b>
    </div>
    <div id="list">
        <table style="padding-top:0px" width="960" border="0" align="center">
            <tbody>
            <tr>
                <td style="padding-right:20px" align="left">
                    <input id="title_mode" value="" width="198" type="text">
                    <input value="查询" onclick="searchEmail();" type="button">
                </td>
                <td style="padding-right:20px" align="right">
                    <input value="新增记录" onclick="modifyRecord(0);" type="button">
                </td>
            </tr>
            </tbody>
        </table>

        <table width="940" border="0">
            <tbody>
            <tr>
                <td>
                    <b>版块名称</b>
                </td>
                <td>
                    <b>版块公告</b>
                </td>
                <td>
                    <b>操作</b>
                </td>
            </tr>
            <tr id="newRecord" style="display:none">
                <c:forEach items="${communityList}" var="community" varStatus="idx" >
            <tr>
                <td>
                    <input id="community_name${idx.index}"  style="width:150px" width="198" type="text" value="${community.communityName}">

                    <input id="communityid${idx.index}" value="23" type="hidden">
                </td>

                <td>
                    <input id="announce${idx.index}"  style="width:150px" type="text" value="${community.communityAnnouncement}">
                </td>

                <td>
                    <input id="modifybtn${idx.index}" value="修改记录" onclick="showCommunityRecord(${idx.index});" type="button">
                    <%--<input id="deletebtn${idx.index}" value="删除记录" onclick="javascript:deleteRecord(1);" type="button">--%>
                </td>
            </tr>
            </c:forEach>
            <tr>
                <td colspan="4" align="center">
                    首页     上一页     第1页/共7页
                    <a href="javascript:gotoPage(2,10)">下一页 </a>
                    <a href="javascript:gotoPage(7,10)">尾页 </a>
                    <select id="mySelect" width="50" style="width: 40px" onchange="jumpPage();">
                        <option selected="">1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                        <option>5</option>
                        <option>6</option>
                        <option>7</option>
                    </select>
                </td>
            </tr>
            </tbody>
        </table>
        <div id="databuffer" style="display:none">
            <div id="signupbox" style="display:none; align:center">
            </div>
        </div>
    </div>
</div>

<br/><br/><br/><br/>

<form name="communityModify" id="communityForm">
    <input id="commuName" disabled="disabled" type="text" value="版块名字"/>
    <input type="text" id="c_name" name="name_content"/>
    <br/>
    <input id="commuAnnouncement" disabled="disabled" type="text" value="版块公告"/>
    <input type="text" id="c_announcement" name="announcement_content"/>
    <button id="communityModifyBtn" type="submit" class="btn btn-success btn-lg btn-block" name="submitButton">提交</button>
</form>

<script>
    var communityUrl = "<spring:url value="/maintain/communityModify" />";
    var communityForm = $("#communityForm");
    var communityModifyBtn = $("#communityModifyBtn");

    communityModifyBtn.click(function () {
        $.ajax({
            type: "POST",
            cache: false,
            async: false,
            url: communityUrl,
            data: communityForm.serialize(),
            dataType: "json",
            success: function (data) {
                if (data.success) {
                    alert(data.msg);
                    location.reload(true);
                } else {
                    alert(data.msg);
                }
            },
            error: function (data) {
                alert("修改失败");
            }
        });
        return false;
    });
</script>